package mvc.helix;


import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.awt.event.MouseMotionListener;


import org.geom.Point2D;
import org.geom.Vector3D;

public class HelixMouseController2D extends HelixSetter 
implements MouseListener, MouseMotionListener{


	//---------------------------------------------------------------------- class var
	private HelixView2D view;
	
	private Point2D mouseDown = new Point2D();
	private Vector3D translate_offset ;	
	private int deltax; // mouse movement delta
	private int deltay;
	
		
	public HelixMouseController2D(HelixModel model, String plane, HelixView2D view2d) {//, Block block) {
		super(model);
		this.view = view2d;
		this.model = model;
	}

	
	//---------------------------------------------------------------------- interface

	public void mousePressed(MouseEvent e) {
		mouseDown = new Point2D(e.getX(), e.getY());
		translate_offset = view.getTranslate();
		System.out.println("helixMouseController2D > mousePRessed ");
	}

	public void mouseDragged(MouseEvent e) {
		deltax = e.getX() - (int)mouseDown.x + (int)translate_offset.x;
		deltay = e.getY() - (int)mouseDown.y + (int)translate_offset.y;

		//mouseDown.x = e.getX();
		//mouseDown.y = e.getY();
		
		mouseMoved(e);
		
		view.setTranslate(new Vector3D(deltax, deltay, 0));
		view.repaint();
	}
	
	public void mouseReleased(MouseEvent e) {
	}
		
	//---------------------------------------------------------------------- privates
	
	@Override
	public void mouseClicked(MouseEvent e) {
		// TODO Auto-generated method stub	
	}
	@Override
	public void mouseEntered(MouseEvent e) {
		// TODO Auto-generated method stub	
	}
	@Override
	public void mouseExited(MouseEvent e) {
		// TODO Auto-generated method stub	
	}
	@Override
	public void mouseMoved(MouseEvent e) {
		// TODO Auto-generated method stub	
	}
}
